# Maintainer: Bruno Pagani <archange@archlinux.org>
# Contributor: Remi Gacogne <rgacogne@archlinux.org>

pkgname=getdns
pkgver=1.7.3
pkgrel=1
pkgdesc="Modern asynchronous DNS API"
arch=(loong64 x86_64)
url="https://getdnsapi.net"
license=(BSD)
depends=(libbsd libev libevent libidn2 libuv libyaml unbound check)
makedepends=(cmake)
source=("${url}/dist/${pkgname}-${pkgver}.tar.gz"{,.asc})
sha256sums=(f1404ca250f02e37a118aa00cf0ec2cbe11896e060c6d369c6761baea7d55a2c SKIP)
validpgpkeys=(DC34EE5DB2417BCC151E5100E5F8F8212F77A498) # Willem Toorop <willem@nlnetlabs.nl>

build() {
  cmake -B build -S ${pkgname}-${pkgver} \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_SYSCONFDIR=/etc \
    -DCMAKE_BUILD_TYPE=Release \
    -DENABLE_STATIC=OFF \
    -DCURRENT_DATE=$(date -u --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" "+%Y-%m-%dT%H:%M:%SZ") \
    -DPATH_TRUST_ANCHOR_FILE=/etc/trusted-key.key
  make -C build
}

package() {
  make -C build DESTDIR="${pkgdir}" install
  install -Dm644 ${pkgname}-${pkgver}/LICENSE -t "${pkgdir}"/usr/share/licenses/${pkgname}/
}
